• 2024-01-21
  • unique

VI write file with sudo

If you opened a file as a normal user and made changes which you now cannot write because you need root permissions, you can use the following shortcut to sudo write the file. Close the file after writing it and reopen it with sudo if you need to make more changes.

:w !sudo tee %